<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* #cc{
            height: 30px;
            margin:  0 auto;
            margin-top: 20px;
            display: flex;
            align-items: center;
            background-color: violet;

        } */
        .box{
            height: 30px;
            width: 800px;
            background-color: yellow;
            margin: 0 auto;
            display: flex;
            align-items: center;
            position: relative;
            margin-top: 20px;
            position: relative;
        }
        .dong{
            width: 0px;
            height: 30px;
            margin: 0 auto;
            line-height: 30px;
            background-color: red;
            position:absolute;


        }
       #bai{
           position:absolute;
           right: 0;
       }
    </style>
</head>
<body>
        <div class="box"  id="dd">
            <div class="dong" id="bb">
                <span id="bai"></span>
            </div>
        </div>
    

</body>
</html>
<script>
    window.onload=function(){
        var le=0
       
            setInterval(function(){
            le+=20
            bb.style.width=le+'px'
            if(le>800){
                le=800
            }
            bai.innerHTML=le/800+'%'
        },400)
        

    }
</script>